package com.resign.carl.prototype.api;

import org.apache.commons.lang3.StringUtils;

/**
 * 账户类，充当抽象类
 * Created by carl.zhao on 2016/6/15.
 */
public abstract class Account {

    private static final String USERNAME = "carl";
    private static final String PASSWORD = "123456";

    public void handle(String account, String password){
        if(!validateAccount(account, password)){
            System.out.println("用户名或密码错误");
            return;
        }
        calculateInterest();
        dispay();
    }

    public abstract void calculateInterest();

    private boolean validateAccount(String account, String password){
        if(StringUtils.isBlank(account) || StringUtils.isBlank(password)){
            return false;
        }
        if(USERNAME.equals(account) && PASSWORD.equals(password)){
            return true;
        }
        return false;
    }

    private void dispay(){
        System.out.println("显示利息");
    }

}
